<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <title>跳转</title>
</head>
<body style="position: relative">

</body>
<script src="js/libs/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
    //获取url后的参数值
    function getUrlParam(key) {
        var href = window.location.href;
        var url = href.split("?");
        if (url.length <= 1) {
            return "";
        }
        var params = url[1].split("&");
        for (var i = 0; i < params.length; i++) {
            var param = params[i].split("=");
            if (key == param[0]) {
                return param[1];
            }
        }
    }

    $.ajax({
        type: 'get',
        url: '/mOverseeQuestions/OA/Login',
        data: {id: getUrlParam("id")},
        success: function (data) {
            var obj = JSON.parse(data);
            var url = obj.ul;
            $.ajax({
                type: 'post',
                url: '/login',
                data: {username: obj.username, password: obj.mwPassword},
                success: function (data) {
                    localStorage.setItem("token", data.token);
                    if (getUrlParam("id") == 0){
                        location.href = '/index.html';
                    }else if (url.indexOf("delFile") != -1) {
                        localStorage.setItem("url", url);
                        location.href = '/index.html';
                    } else {
                        location.href = url;
                    }
                },
                error: function (xhr, textStatus, errorThrown) {
                    var msg = xhr.responseText;
                    var response = JSON.parse(msg);
                    $("#info").html(response.message);
                    $(obj).attr("disabled", false);
                }
            });
        },
        error: function (xhr, textStatus, errorThrown) {
            var msg = xhr.responseText;
            var response = JSON.parse(msg);
            alert(response.message);
        }
    });

</script>
</html>